package com.stadium.service.impl;

import com.stadium.common.utils.SqlMapper;
import com.stadium.dto.RRuleDetailDto;
import com.stadium.entity.RRuleDetail;
import com.stadium.mapper.RRuleDetailMP;
import com.stadium.service.RRuleDetailSV;
import com.stadium.vo.RRuleDetailVo;
import com.stadium.vo.searchVo.RRuleDetailSearchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
@Transactional
public class RRuleDetailSVI  implements RRuleDetailSV {
	@Autowired
	private RRuleDetailMP mapper;
	@Autowired
	private SqlMapper sqlMapper;

	@Override
	public List<RRuleDetail> queryBySQL(String sql,Map<String, Object> map) {
		return sqlMapper.selectList(sql, map, RRuleDetail.class);
	}

    @Override
    public void save(RRuleDetailVo rRuleDetailVo) {
        RRuleDetail rRuleDetail = new  RRuleDetail();
        BeanUtils.copyProperties(rRuleDetailVo,rRuleDetail);
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        rRuleDetail.setId(id);
        mapper.save(rRuleDetail);
    }

    @Override
    public void update(RRuleDetailVo rRuleDetailVo) {
        RRuleDetail rRuleDetail = new  RRuleDetail();
        BeanUtils.copyProperties(rRuleDetailVo,rRuleDetail);
        mapper.update(rRuleDetail);
    }

    @Override
    public void saveBatch(List<RRuleDetail> list) {
        mapper.saveBatch(list);
    }

    @Override
    public void delete(String id) {
        mapper.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        mapper.deleteBatch(ids);
    }


    @Override
    public List<RRuleDetailDto> query(RRuleDetailSearchVo searchVo) {
        return mapper.query(searchVo);
    }

    @Override
    public RRuleDetailDto get(String id) {
        return mapper.get(id);
    }

    @Override
    public int getCount(RRuleDetailSearchVo searchVo) {
        return mapper.getCount(searchVo);
    }

    @Override
    public RRuleDetail getByCode(String code) {
        return mapper.getByCode(code);
    }
}
